package com.tang.algorithm.ordinary;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tlm
 * @version 1.0
 * @date 2020/7/24 20:37
 */
public class LeetCode1476 {
    class SubrectangleQueries {

        Map<Integer, int[]> map;
        public SubrectangleQueries(int[][] rectangle) {
            map = new HashMap<>();

            for (int i = 0; i < rectangle.length; i++)
                map.put(i, rectangle[i]);
        }

        public void updateSubrectangle(int row1, int col1, int row2, int col2, int newValue) {

            for (int i = row1; i <= row2; i++) {
                int[] temp = map.get(i);
                for (int j = col1; j <= col2; j++)
                    temp[j] = newValue;
                map.put(i, temp);
            }

        }

        public int getValue(int row, int col) {
            if (map.containsKey(row)) {
                int[] ans = map.get(row);
                return ans[col];
            }
            return -1;
        }
    }
}
